

<template>
  <el-dialog
    center
    :visible="dialogProjectVisible"
    width="1200px"
    title="项目详情"
    append-to-body
    :before-close="handleProjectClose"
    @closed="handleProjectClose"
    :close-on-click-modal="false"
  >
    <el-form
      ref="ruleForm"
      size="small"
      :model="ruleForm"
      :rules="rules"
      label-width="120px"
      disabled
    >

      <el-card class="box-card">
        <el-row :gutter="10">
          <el-col :span="8">
            <el-form-item label="项目租赁类型">
              <el-radio-group v-model="ruleForm.projectBasicVo.rentType">
                <el-radio label="01">直租</el-radio>
                <el-radio label="02">回租</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="16">
            <el-form-item label="项目所在区域">
              <hsk-address-sel
                :inputNumShow="inputNumShow"
                :inputInterval="inputInterval"
                @addressChange="addressChange"
                :defaultAddress="defaultProjectAddress"
              />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <div style="display: flex; align-items: center;">
              <el-form-item
                label="推荐代理人"
                prop="projectBasicVo.agentName"
              >
                <el-input
                  v-model="ruleForm.projectBasicVo.agentName"
                  placeholder="请选择推荐代理人"
                ></el-input>
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="8">
            <div style="display: flex; align-items: center;">
              <el-form-item
                label="选择客户"
                prop="customerAdmitVo.customerAdmitInfo.customerName"
              >
                <el-input
                  readonly
                  v-model="ruleForm.customerAdmitVo.customerAdmitInfo.customerName"
                  placeholder="请选择客户"
                >
                </el-input>
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="8">
            <div style="display: flex; align-items: center;">
              <el-form-item
                label="选择出租方"
                prop="projectBasicVo.lessorId"
              >
                <el-select v-model="ruleForm.projectBasicVo.lessorId">
                  <el-option
                    v-for="item in lessorList"
                    :value="item.companyId"
                    :label="item.companyName"
                    :key="item.companyId"
                  />
                </el-select>
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="24">
            {{fileTemplate["project_initiation_report"]?.remark}}<el-link
              type="primary"
              :href="fileTemplate['project_initiation_report']?.value"
            >模板下载</el-link>
          </el-col>
          <el-col
            :span="24"
            style="height: 50px;display: flex;align-items: center;"
          >
            <el-upload
              class="upload-demo"
              ref="uploadApplicationFile"
              :accept="fileAccept"
              :action="uploadFileUrl + '/file/saveFile'"
              :before-upload="beforeUpload"
              :on-change="handleApplicationChange"
              :on-success="handleApplicationSuccess"
              :on-remove="handleApplicationRemove"
              :file-list="applicationFile"
              :data="{fileRemark: '', fileuserInfo: ''}"
              :multiple="false"
              :auto-upload="true"
            >
              <el-button
                size="mini"
                type="primary"
                plain
              >点击上传</el-button>
              <el-button
                v-if="this.ruleForm.projectBasicVo.applicationFileId"
                :disabled="false"
                size="mini"
                type="primary"
                @click="downloadFile({fileUuid: ruleForm.projectBasicVo.applicationFileId})"
              >下载</el-button>
              <el-button
                v-if="this.ruleForm.projectBasicVo.applicationFileId"
                :disabled="false"
                size="mini"
                type="primary"
                @click="handlePreviewFile({fileUuid: ruleForm.projectBasicVo.applicationFileId})"
              >预览</el-button>
            </el-upload>
          </el-col>
        </el-row>
      </el-card>
      <el-card class="box-card">
        <div class="box">
          <div class="title">客户基本信息</div>
          <el-form
            size="small"
            :model="ruleForm.customerAdmitVo.customerAdmitInfo"
            label-width="170px"
          >
            <el-row :gutter="10">
              <template v-if="ruleForm.customerAdmitVo.customerAdmitInfo.customerType === '01'">
                <el-col :span="6">
                  <div
                    class="up_sy_logo_div"
                    style="margin-left: 27px;"
                  >
                    <!--支持点击查看大图-->
                    <el-image
                      style="width:267px;height:377px;"
                      :src="ruleForm.customerAdmitVo.customerAdmitInfo.hrefn"
                      :preview-src-list="[ruleForm.customerAdmitVo.customerAdmitInfo.hrefn]"
                    ></el-image>
                  </div>
                </el-col>
                <el-col :span="18">
                  <el-row :gutter="10">
                    <el-col :span="12">
                      <el-form-item label="企业名称：">
                        {{ruleForm.customerAdmitVo.customerAdmitInfo.enterprieName}}
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="统一社会信用代码：">
                        {{ruleForm.customerAdmitVo.customerAdmitInfo.creditCode}}
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="法定代表人：">
                        {{ruleForm.customerAdmitVo.customerAdmitInfo.legalpersonName}}
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="成立时间：">
                        {{ruleForm.customerAdmitVo.customerAdmitInfo.companySetDate}}
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="行政区划：">
                        {{ruleForm.customerAdmitVo.customerAdmitInfo.companyWordaddress}}
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="注册资本：">
                        {{formatMoney(ruleForm.customerAdmitVo.customerAdmitInfo.registerFund / 10000)}}万元
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="实缴资本：">
                        {{formatMoney(ruleForm.customerAdmitVo.customerAdmitInfo.realityFund / 10000)}}万元
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="企业类型：">
                        {{ruleForm.customerAdmitVo.customerAdmitInfo.companyNature}}
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="经营范围：">
                        {{ruleForm.customerAdmitVo.customerAdmitInfo.businessScope}}
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="办公电话：">
                        {{ruleForm.customerAdmitVo.customerAdmitInfo.companyTel}}
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="资产情况描述：">
                        {{ruleForm.customerAdmitVo.customerAdmitInfo.assetCondition}}
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="职工人数：">
                        {{ruleForm.customerAdmitVo.customerAdmitInfo.staffNumber}}
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="法人身份证号：">
                        {{ruleForm.customerAdmitVo.customerAdmitInfo.legalpersonCreditcode}}
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="公司征信：">
                        {{creditEnum[ruleForm.customerAdmitVo.customerAdmitInfo.companyCredit]}}
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="营业期限：">
                        {{ruleForm.customerAdmitVo.customerAdmitInfo.businessStart}} 至 {{ruleForm.customerAdmitVo.customerAdmitInfo.businessEnd}}
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="公司基本情况描述：">
                        {{ruleForm.customerAdmitVo.customerAdmitInfo.companyCondition}}
                      </el-form-item>
                    </el-col>
                    <el-col :span="12">
                      <el-form-item label="注册地址：">
                        {{ruleForm.customerAdmitVo.customerAdmitInfo.companyAddress}}
                      </el-form-item>
                    </el-col>
                  </el-row>
                </el-col>
              </template>
              <template v-if="ruleForm.customerAdmitVo.customerAdmitInfo.customerType === '02'">
                <el-col :span="6">
                  <el-row>
                    <div
                      class="up_sy_logo_div"
                      style="margin-left: 27px;"
                    >
                      <el-image
                        v-if="ruleForm.customerAdmitVo.customerAdmitInfo.frontFn"
                        style="width:267px;height:180px;"
                        :src="ruleForm.customerAdmitVo.customerAdmitInfo.frontFn"
                        :preview-src-list="ruleForm.customerAdmitVo.customerAdmitInfo.frontFn ? [ruleForm.customerAdmitVo.customerAdmitInfo.frontFn] : []"
                      ></el-image>
                    </div>
                  </el-row>
                  <el-row>
                    <div
                      class="up_sy_logo_div"
                      style="margin-left: 27px;"
                    >
                      <el-image
                        v-if="ruleForm.customerAdmitVo.customerAdmitInfo.backFn"
                        style="width:267px;height:180px;"
                        :src="ruleForm.customerAdmitVo.customerAdmitInfo.backFn"
                        :preview-src-list="ruleForm.customerAdmitVo.customerAdmitInfo.backFn ? [ruleForm.customerAdmitVo.customerAdmitInfo.backFn] : []"
                      ></el-image>
                    </div>
                  </el-row>
                </el-col>
                <el-col :span="18">
                  <el-col :span="12">
                    <el-form-item
                      label="姓名："
                      prop="customerName"
                    >
                      {{ruleForm.customerAdmitVo.customerAdmitInfo.customerName}}
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item
                      label="家庭住址："
                      prop="personalAddress"
                    >
                      {{ruleForm.customerAdmitVo.customerAdmitInfo.personalAddress}}
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item
                      label="性别："
                      prop="customerSex"
                    >
                      <dict-tag
                        :options="dict.type.sys_user_sex"
                        :value="ruleForm.customerAdmitVo.customerAdmitInfo.customerSex"
                      />
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item
                      label="户籍所在地："
                      prop="personalHousehold"
                    >
                      {{ruleForm.customerAdmitVo.customerAdmitInfo.personalHousehold}}
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item
                      label="身份证号码："
                      prop="customerCreditcode"
                    >
                      {{ruleForm.customerAdmitVo.customerAdmitInfo.customerCreditcode}}
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item
                      label="工作单位"
                      prop="personalWorkaddress"
                    >
                      {{ruleForm.customerAdmitVo.customerAdmitInfo.personalWorkaddress}}
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item
                      label="出生日期"
                      prop="birthDate"
                    >
                      {{ruleForm.customerAdmitVo.customerAdmitInfo.birthDate}}
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item
                      label="个人征信："
                      prop="personalCredit"
                    >
                      {{creditEnum[ruleForm.customerAdmitVo.customerAdmitInfo.personalCredit]}}
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item
                      label="电话号码："
                      prop="customerPhone"
                    >
                      {{ruleForm.customerAdmitVo.customerAdmitInfo.customerPhone}}
                    </el-form-item>
                  </el-col>
                  <!-- <el-col :span="12">
                    <el-form-item
                      label="客户评级："
                      prop="customerRate"
                    >
                      {{ruleForm.customerAdmitVo.customerAdmitInfo.customerRate}}
                    </el-form-item>
                  </el-col> -->
                  <el-col :span="12">
                    <el-form-item
                      label="民族："
                      prop="customerNation"
                    >
                      <dict-tag
                        :options="dict.type.sys_nation"
                        :value="ruleForm.customerAdmitVo.customerAdmitInfo.customerNation"
                      />
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item
                      label="学历："
                      prop="customerEduc"
                    >
                      <dict-tag
                        :options="dict.type.sys_education"
                        :value="ruleForm.customerAdmitVo.customerAdmitInfo.customerEduc"
                      />
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item
                      label="婚姻状况："
                      prop="customerMarriage"
                    >
                      {{marriageEnum[ruleForm.customerAdmitVo.customerAdmitInfo.customerMarriage]}}
                    </el-form-item>
                  </el-col>
                </el-col>
              </template>
            </el-row>
            <el-row>
              <el-col
                :span="6"
                v-if="ruleForm.customerAdmitVo.customerAdmitInfo.customerinfoFile"
              >
                <i class="tz-icon-ppt" />
                <el-link
                  type="primary"
                  @click="downloadFile({fileUuid: ruleForm.customerAdmitVo.customerAdmitInfo.customerinfoFile})"
                >《客户基本信息表》</el-link>
                <el-link
                  type="primary"
                  size="mini"
                  @click="handlePreviewFile({ fileUuid: ruleForm.customerAdmitVo.customerAdmitInfo.customerinfoFile})"
                >预览</el-link>
              </el-col>
              <el-col
                :span="6"
                v-if="ruleForm.customerAdmitVo.customerAdmitInfo.applyFile"
              >
                <i class="tz-icon-doc" />
                <el-link
                  type="primary"
                  @click="downloadFile({fileUuid: ruleForm.customerAdmitVo.customerAdmitInfo.applyFile})"
                >《融资租赁申请书》</el-link>
                <el-link
                  type="primary"
                  size="mini"
                  @click="handlePreviewFile({ fileUuid: ruleForm.customerAdmitVo.customerAdmitInfo.applyFile})"
                >预览</el-link>
              </el-col>
              <el-col
                :span="6"
                v-if="ruleForm.customerAdmitVo.customerAdmitInfo.supplementFileList && ruleForm.customerAdmitVo.customerAdmitInfo.supplementFileList.length > 0"
              >
                <i class="tz-icon-pdf" />
                <el-link
                  type="primary"
                  @click="downloadFileList(ruleForm.customerAdmitVo.customerAdmitInfo.supplementFileList)"
                >其他补充材料</el-link>
                <el-link
                  type="primary"
                  size="mini"
                  style="margin-left: 10px"
                  v-for="(item, index) in ruleForm.customerAdmitVo.customerAdmitInfo.supplementFileList"
                  :key="index"
                  @click="handlePreviewFile({ fileUuid: item.fileUuid})"
                >{{item.fileName}}预览</el-link>
              </el-col>
            </el-row>
          </el-form>
        </div>
      </el-card>
      <el-card class="box-card">
        <div class="box">
          <div class="title">
            <div>开户行信息</div>
          </div>
          <el-table
            :data="ruleForm.bankAccountList"
            style="width: 100%; margin-bottom: 20px"
          >
            <el-table-column
              label="银行卡号"
              prop="bankCardno"
            />
            <el-table-column
              label="银行名称"
              prop="bankName"
            />
            <el-table-column
              label="开户行名称"
              prop="bankOpenname"
            />
            <el-table-column
              label="银行开户名"
              prop="bankCutname"
            />
          </el-table>
        </div>
      </el-card>
      <el-card class="box-card">
        <div class="box">
          <div class="title">
            <div>发票信息</div>
          </div>
          <el-row :gutter="10">
            <el-col :span="8">
              <el-form-item label="发票抬头">
                <el-input
                  v-model="ruleForm.projectBasicVo.invoice_title"
                  :style="{width: '100%'}"
                  :disabled="true"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="税号">
                <el-input
                  v-model="ruleForm.projectBasicVo.tax_no"
                  :style="{width: '100%'}"
                  :disabled="true"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="开户行">
                <el-input
                  v-model="ruleForm.projectBasicVo.invoice_bank"
                  placeholder="请输入开户行"
                  :style="{width: '100%'}"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="联系电话">
                <el-input
                  v-model="ruleForm.projectBasicVo.invoice_tle"
                  placeholder="请输入联系电话"
                  :style="{width: '100%'}"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="银行账号">
                <el-input
                  v-model="ruleForm.projectBasicVo.invoice_account"
                  placeholder="请输入银行账号"
                  :style="{width: '100%'}"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="16">
              <el-form-item label="地址">
                <el-input
                  v-model="ruleForm.projectBasicVo.invoice_address"
                  placeholder="请输入地址"
                  :style="{width: '100%'}"
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </div>
      </el-card>
      <el-card class="box-card">
        <div class="box">
          <div class="title">
            <div>邮寄地址</div>
          </div>
          <el-row :gutter="10">
            <el-col :span="8">
              <el-form-item
                label="收件人名称"
                prop="recipientName"
              >
                <el-input
                  v-model="ruleForm.projectBasicVo.recipientName"
                  placeholder="请输入收件人名称"
                  clearable
                >
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                label="收件人电话"
                prop="recipientPhone"
              >
                <el-input
                  v-model="ruleForm.projectBasicVo.recipientPhone"
                  placeholder="请输入收件人电话"
                  clearable
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="16">
              <el-form-item label="所在区域">
                <hsk-address-sel
                  :inputNumShow="inputNumShow"
                  :inputInterval="inputInterval"
                  @addressChange="addressChanges"
                  :defaultAddress="defaultMailAddress"
                />
              </el-form-item>
            </el-col>
            <el-col :span="16">
              <el-form-item
                label="详细地址"
                prop="detailedAddress"
              >
                <el-input
                  v-model="ruleForm.projectBasicVo.mailDetailAddr"
                  placeholder="请输入详细地址"
                  clearable
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </div>
      </el-card>
      <el-card class="box-card">
        <div class="box">
          <div class="title">
            <div>设备信息</div>
          </div>
          <el-table
            :data="ruleForm.equipmentVos"
            show-summary
            ref="table"
            :key="tableKey"
            style="width: 100%; margin-bottom: 20px"
            :summary-method="getSummaries"
          >
            <el-table-column
              label="设备名称"
              width="300"
              prop="equipmentName"
            ></el-table-column>
            <el-table-column
              label="规格型号"
              width="130"
              prop="equipmentModel"
            ></el-table-column>
            <el-table-column
              label="单位"
              width="100"
              prop="unit"
            ></el-table-column>
            <el-table-column
              label="配置信息"
              prop="configInfo"
            >
              <template #default="{row}">
                <el-input
                  v-model="row.configInfo"
                  placeholder="请输入配置信息"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column
              label="数量"
              width="100"
              prop="num"
            >
              <template #default="{row}">
                <el-input
                  v-model="row.num"
                  type="number"
                  :min="1"
                  placeholder="请输入数量"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column
              label="单价（元）"
              width="130"
              prop="price"
            >
              <template #default="{row}">
                <el-input
                  v-model="row.price"
                  placeholder="请输入单价"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column
              label="总价（元）"
              width="150"
              prop="totalPrice"
            >
              <template #default="{row}">
                {{ handlePrice(row) }}
              </template>
            </el-table-column>
          </el-table>
        </div>
      </el-card>
      <el-card class="box-card">
        <div class="box">
          <div class="title">租赁意向方案</div>
          <el-row :gutter="10">
            <el-col :span="6">
              <el-form-item
                label="合同价款"
                prop="rentCalculateVo.calculateInfo.leasingPrice"
              >
                <el-input
                  v-model="ruleForm.rentCalculateVo.calculateInfo.leasingPrice"
                  placeholder="请输入合同价款"
                  clearable
                >
                  <i slot="suffix">{{formatLeasingPrice}}</i>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                label="融资期限"
                prop="rentCalculateVo.calculateInfo.leaseTermMonths"
              >
                <el-input
                  v-model="ruleForm.rentCalculateVo.calculateInfo.leaseTermMonths"
                  placeholder="请输入融资期限"
                  clearable
                >
                  <i slot="suffix">月</i>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                label="还款周期"
                prop="rentCalculateVo.calculateInfo.repaymentCycle"
              >
                <el-select
                  v-model="ruleForm.rentCalculateVo.calculateInfo.repaymentCycle"
                  @change="handleRepaymentCycleChange"
                >
                  <el-option
                    v-for="item in repaymentCycleOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                label="宽限期"
                prop="gracePeriodMonths"
              >
                <el-tooltip
                  class="item"
                  effect="dark"
                  content="还款周期为月付/双月付/季付/半年付时，宽限期一期分别表示1个月/2个月/3个月/6个月"
                  placement="top"
                >
                  <el-input
                    v-model="ruleForm.rentCalculateVo.calculateInfo.gracePeriodMonths"
                    placeholder="请输入宽限期"
                    clearable
                    :style="{width: '100%'}"
                  >
                    <i slot="suffix">期</i>
                  </el-input>
                </el-tooltip>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                label="起始日期"
                prop="startDay"
              >
                <el-date-picker
                  v-model="ruleForm.rentCalculateVo.calculateInfo.startDay"
                  type="date"
                  placeholder="选择日期"
                  :style="{width: '100%'}"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                label="停歇期"
                prop="breakPeriod"
              >
                <el-select
                  v-model="ruleForm.rentCalculateVo.calculateInfo.breakPeriod"
                  style="width: 130px"
                  multiple
                  collapse-tags
                  :multiple-limit="5"
                  :disabled="ruleForm.rentCalculateVo.calculateInfo.repaymentCycle !== 'MONTHLY'"
                >
                  <el-option
                    v-for="item in breakPeriodOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                label="还款方式"
                prop="repaymentMethod"
              >
                <el-select
                  v-model="ruleForm.rentCalculateVo.calculateInfo.repaymentMethod"
                  :style="{width: '100%'}"
                >
                  <el-option
                    v-for="item in repaymentMethodOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                label="名义收益率"
                prop="nominalInterestRate"
              >
                <el-input
                  v-model="ruleForm.rentCalculateVo.calculateInfo.nominalInterestRate"
                  placeholder="请输入名义收益率"
                  clearable
                  :style="{width: '100%'}"
                >
                  <i slot="suffix">%</i>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                label="保证金抵扣方式"
                prop="marginDeductionMethod"
              >
                <el-select
                  v-model="ruleForm.rentCalculateVo.calculateInfo.marginDeductionMethod"
                  :style="{width: '100%'}"
                  :disabled="true"
                >
                  <el-option
                    v-for="item in marginDeductionMethodOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                label="还租时点"
                prop="rentPaymentTiming"
              >
                <el-select
                  v-model="ruleForm.rentCalculateVo.calculateInfo.rentPaymentTiming"
                  :style="{width: '100%'}"
                >
                  <el-option
                    v-for="item in rentPaymentTimingOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                label="手续费税率"
                prop="feeTaxRate"
              >
                <el-select
                  v-model="ruleForm.rentCalculateVo.calculateInfo.feeTaxRate"
                  :style="{width: '100%'}"
                >
                  <el-option
                    v-for="item in feeTaxRateOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                label="租赁方式"
                prop="leasingMethod"
              >
                <el-select
                  v-model="ruleForm.rentCalculateVo.calculateInfo.leasingMethod"
                  :style="{width: '100%'}"
                  :disabled="true"
                >
                  <el-option
                    v-for="item in leasingMethodOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                label="首付款"
                prop="downPayment"
              >
                <el-input
                  v-model="ruleForm.rentCalculateVo.calculateInfo.downPayment"
                  placeholder="请输入首付款"
                  clearable
                  :style="{width: '100%'}"
                >
                  <i slot="suffix">{{formatDownPayment}}</i>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                label="首付款比例"
                prop="downPaymentPercentage"
              >
                <el-input
                  v-model="downPaymentPercentage"
                  placeholder="请输入首付款比例"
                  :disabled="true"
                  :style="{width: '100%'}"
                >
                  <i slot="suffix">%</i>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                label="保证金"
                prop="margin"
              >
                <el-input
                  v-model="ruleForm.rentCalculateVo.calculateInfo.margin"
                  placeholder="请输入保证金"
                  clearable
                  :style="{width: '100%'}"
                >
                  <i slot="suffix">{{formatMargin}}</i>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                label="保证金比例"
                prop="marginPercentage"
              >
                <el-input
                  v-model="marginPercentage"
                  placeholder="请输入保证金比例"
                  clearable
                  :style="{width: '100%'}"
                  :disabled="true"
                >
                  <i slot="suffix">%</i>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                label="手续费"
                prop="fees"
              >
                <el-input
                  v-model="ruleForm.rentCalculateVo.calculateInfo.fees"
                  placeholder="请输入手续费"
                  clearable
                  :style="{width: '100%'}"
                >
                  <i slot="suffix">{{formatFees}}</i>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                label="手续费率(年)"
                prop="feeRatePerYear"
              >
                <el-input
                  v-model="feeRatePerYear"
                  placeholder="请输入手续费率"
                  clearable
                  :style="{width: '100%'}"
                  :disabled="true"
                >
                  <i slot="suffix">%</i>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                label="资金成本率"
                prop="capitalCostRate"
              >
                <el-input
                  v-model="ruleForm.rentCalculateVo.calculateInfo.capitalCostRate"
                  placeholder="请输入资金成本率"
                  clearable
                  :style="{width: '100%'}"
                >
                  <i slot="suffix">%</i>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                label="其他收入(含税)"
                prop="otherIncomeTaxIncluded"
              >
                <el-input
                  v-model="ruleForm.rentCalculateVo.calculateInfo.otherIncomeTaxIncluded"
                  placeholder="请输入其他收入"
                  clearable
                  :style="{width: '100%'}"
                >
                  <i slot="suffix">{{formatOtherIncomeTaxIncluded}}</i>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                label="出租人其他成本(月)"
                prop="lessorOtherCosts"
              >
                <el-input
                  v-model="ruleForm.rentCalculateVo.calculateInfo.lessorOtherCosts"
                  placeholder="请输入出租人其他成本"
                  clearable
                >
                  <i slot="suffix">{{formatLessorOtherCosts}}</i>
                </el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <div style="margin-top: 10px; display: flex; justify-content: center;">
            <el-button
              type="primary"
              size="small"
              @click="handleImitateOpen"
              :disabled="false"
            >模拟计算</el-button>
          </div>
        </div>
      </el-card>
      <el-card class="box-card">
        <div class="box">
          <div class="title">
            <span>
              融资清单资料 {{fileTemplate["finance_lease_data_list"]?.remark}}
              <el-link
                style="font-size: 19px;"
                type="primary"
                @click="downloadTemplateFile(fileTemplate['finance_lease_data_list'].value)"
              >模板下载</el-link>
            </span>
          </div>
          <el-table
            :data="ruleForm.fileVo.FINANCING"
            style="width: 100%; margin-bottom: 20px"
          >
            <el-table-column
              label="序号"
              width="80"
            >
              <template #default="scope">{{ scope.$index + 1 }}</template>
            </el-table-column>
            <el-table-column
              label="附件名称"
              prop="fileName"
            >
              <template #default="{row}">
                <el-input
                  v-model="row.fileName"
                  placeholder="请输入附件名称"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column
              label="附件说明"
              prop="fileRemark"
            >
              <template #default="{row}">
                <el-input
                  v-model="row.fileRemark"
                  placeholder="请输入附件说明"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column
              label="附件上传"
              prop="fileDesc"
            >
              <template #default="scope">
                <el-upload
                  class="upload-demo"
                  :ref="'uploadFile' + '1'  + '_' + scope.$index"
                  :accept="fileAccept"
                  :action="uploadFileUrl + '/file/saveFile'"
                  :before-upload="beforeUpload"
                  :on-change="(file, fileList) => handleChange(file, fileList, scope.row)"
                  :on-success="(response, file, fileList) => handleSuccess(response, file, fileList, scope.row, scope.$index, 'uploadFile' + '1'  + '_' + scope.$index)"
                  :on-remove="(file, fileList) => handleRemove(file, fileList, scope.row)"
                  :file-list="scope.row.fileList"
                  :data="{fileRemark: scope.row.fileRemark, fileuserInfo: scope.row.fileName}"
                  :multiple="false"
                  :auto-upload="true"
                >
                  <el-button
                    size="small"
                    type="primary"
                    class="el-icon-upload2"
                  ></el-button>
                </el-upload>
              </template>
            </el-table-column>
            <el-table-column
              label="操作"
              width="120"
            >
              <template #default="scope">
                <div style="display: flex; justify-content: space-around;">
                  <el-link
                    type="primary"
                    size="mini"
                    :disabled="false"
                    @click="downloadFile(scope.row)"
                  >下载</el-link>
                  <el-link
                    type="primary"
                    size="mini"
                    :disabled="false"
                    @click="handlePreviewFile({ fileUuid: scope.row.fileUuid})"
                  >预览</el-link>
                </div>
              </template>
            </el-table-column>
          </el-table>
          <div style="margin-bottom: 10px;">补充说明</div>
          <el-input
            v-model="ruleForm.projectBasicVo.financeingDesc"
            placeholder="请输入补充说明"
            clearable
            type="textarea"
            :autosize="{ minRows: 2, maxRows: 4}"
          ></el-input>
        </div>
      </el-card>
      <el-card class="box-card">
        <div class="box">
          <div class="title">
            <span>
              承租企业近年主要财务指标 {{fileTemplate["financial_indicators"]?.remark}}
              <el-link
                style="font-size: 19px;"
                type="primary"
                @click="downloadTemplateFile(fileTemplate['financial_indicators'].value)"
              >模板下载</el-link>
            </span>
          </div>
          <el-form-item label="附件上传">
            <el-upload
              class="upload-demo"
              ref="uploadFinanceFile"
              :accept="fileAccept"
              :action="uploadFileUrl + '/file/saveFile'"
              :before-upload="beforeUpload"
              :on-change="handleFinanceChange"
              :on-success="handleFinanceSuccess"
              :on-remove="handleFinanceRemove"
              :file-list="financeFile"
              :data="{fileRemark: '', fileuserInfo: ''}"
              :multiple="false"
              :auto-upload="true"
            >
              <el-button
                size="small"
                type="primary"
                class="el-icon-upload2"
              >点击上传</el-button>
              <el-button
                :disabled="false"
                v-if="this.ruleForm.projectBasicVo.financeFileId"
                size="small"
                type="primary"
                @click="downloadFile({fileUuid: ruleForm.projectBasicVo.financeFileId})"
              >下载</el-button>
              <el-button
                :disabled="false"
                v-if="this.ruleForm.projectBasicVo.financeFileId"
                size="small"
                type="primary"
                @click="handlePreviewFile({fileUuid: ruleForm.projectBasicVo.financeFileId})"
              >预览</el-button>
            </el-upload>
          </el-form-item>
        </div>
        <div class="box">
          <div class="title">
            <span>
              承租企业近期融资情况 {{fileTemplate["financing_situation"]?.remark}}
              <el-link
                style="font-size: 19px;"
                type="primary"
                @click="downloadTemplateFile(fileTemplate['financing_situation'].value)"
              >模板下载</el-link>
            </span>
          </div>
          <el-form-item label="附件上传">
            <el-upload
              class="upload-demo"
              ref="uploadApplyDescFile"
              :accept="fileAccept"
              :action="uploadFileUrl + '/file/saveFile'"
              :before-upload="beforeUpload"
              :on-change="handleApplyDescChange"
              :on-success="handleApplySuccess"
              :on-remove="handleApplyDescRemove"
              :file-list="applyFile"
              :data="{fileRemark: '', fileuserInfo: ''}"
              :multiple="false"
              :auto-upload="true"
            >
              <el-button
                size="small"
                type="primary"
                class="el-icon-upload2"
              >点击上传</el-button>
              <el-button
                :disabled="false"
                v-if="this.ruleForm.projectBasicVo.applyFileId"
                size="small"
                type="primary"
                @click="downloadFile({fileUuid: ruleForm.projectBasicVo.applyFileId})"
              >下载</el-button>
              <el-button
                :disabled="false"
                v-if="this.ruleForm.projectBasicVo.applyFileId"
                size="small"
                type="primary"
                @click="handlePreviewFile({fileUuid: ruleForm.projectBasicVo.applyFileId})"
              >预览</el-button>
            </el-upload>
          </el-form-item>
        </div>
      </el-card>
      <el-card class="box-card">
        <div class="box">
          <div class="title">
            <span>
              担保信息 {{fileTemplate["finance_lease_guarantee_file"]?.remark}}
              <el-link
                style="font-size: 19px;"
                type="primary"
                @click="downloadTemplateFile(fileTemplate['finance_lease_guarantee_file'].value)"
              >模板下载</el-link>
            </span>
          </div>
          <el-row :gutter="10">
            <el-col
              :span="24"
              style="display: flex; align-items: center; height: 40px;"
            >
              担保方式：
              <el-checkbox-group
                v-model="ruleForm.projectBasicVo.guaraWay"
                style="width: 600px;"
              >
                <el-checkbox label="01">保证</el-checkbox>
                <el-checkbox label="02">抵押</el-checkbox>
                <el-checkbox label="03">质押</el-checkbox>
                <el-checkbox label="04">回购</el-checkbox>
                <el-checkbox label="05">其他</el-checkbox>
              </el-checkbox-group>
            </el-col>
          </el-row>
          <el-table
            :data="ruleForm.fileVo.GUARANTEE"
            style="width: 100%; margin-bottom: 20px"
          >
            <el-table-column
              label="序号"
              width="80"
            >
              <template #default="scope">{{ scope.$index + 1 }}</template>
            </el-table-column>
            <el-table-column
              label="附件名称"
              prop="fileName"
            >
              <template #default="{row}">
                <el-input
                  v-model="row.fileName"
                  placeholder="请输入附件名称"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column
              label="附件说明"
              prop="fileRemark"
            >
              <template #default="{row}">
                <el-input
                  v-model="row.fileRemark"
                  placeholder="请输入附件说明"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column
              label="附件上传"
              prop="fileDesc"
            >
              <template #default="scope">
                <el-upload
                  class="upload-demo"
                  :ref="'uploadFile' + '2'  + '_' + scope.$index"
                  :accept="fileAccept"
                  :action="uploadFileUrl + '/file/saveFile'"
                  :before-upload="beforeUpload"
                  :on-change="(file, fileList) => handleChange(file, fileList, scope.row)"
                  :on-success="(response, file, fileList) => handleSuccess(response, file, fileList, scope.row, scope.$index, 'uploadFile' + '2'  + '_' + scope.$index)"
                  :on-remove="(file, fileList) => handleRemove(file, fileList, scope.row)"
                  :file-list="scope.row.fileList"
                  :data="{fileRemark: scope.row.fileRemark, fileuserInfo: scope.row.fileName}"
                  :multiple="false"
                  :auto-upload="true"
                >
                  <el-button
                    size="small"
                    type="primary"
                    class="el-icon-upload2"
                  ></el-button>
                </el-upload>
              </template>
            </el-table-column>
            <el-table-column
              label="操作"
              width="150"
            >
              <template #default="scope">
                <div style="display: flex; justify-content: space-around;">
                  <el-link
                    type="primary"
                    size="mini"
                    :disabled="false"
                    @click="downloadFile(scope.row)"
                  >下载</el-link>
                  <el-link
                    type="primary"
                    size="mini"
                    :disabled="false"
                    @click="handlePreviewFile({fileUuid: scope.row.fileUuid})"
                  >预览</el-link>
                </div>
              </template>
            </el-table-column>
          </el-table>
          <div style="margin-bottom: 10px;">补充说明</div>
          <el-input
            v-model="ruleForm.projectBasicVo.guaraDesc"
            placeholder="请输入补充说明"
            clearable
            type="textarea"
            :autosize="{ minRows: 2, maxRows: 4}"
          ></el-input>
        </div>
      </el-card>
      <el-card class="box-card">
        <div class="box">
          <div class="title">项目说明</div>
          <el-input
            v-model="ruleForm.projectBasicVo.projectDesc"
            placeholder="请输入补充说明"
            clearable
            type="textarea"
            :autosize="{ minRows: 2, maxRows: 4}"
          ></el-input>
        </div>
      </el-card>
      <el-card class="box-card">
        <div class="box">
          <div class="title">
            其他补充资料
          </div>
          <el-table
            :data="ruleForm.fileVo.OTHER"
            style="width: 100%; margin-bottom: 20px"
          >
            <el-table-column
              label="序号"
              width="80"
            >
              <template #default="scope">{{ scope.$index + 1 }}</template>
            </el-table-column>
            <el-table-column
              label="附件名称"
              prop="fileName"
            >
              <template #default="{row}">
                <el-input
                  v-model="row.fileName"
                  placeholder="请输入附件名称"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column
              label="附件说明"
              prop="fileRemark"
            >
              <template #default="{row}">
                <el-input
                  v-model="row.fileRemark"
                  placeholder="请输入附件说明"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column
              label="附件上传"
              prop="fileDesc"
            >
              <template #default="scope">
                <el-upload
                  class="upload-demo"
                  :ref="'uploadFile' + '3'  + '_' + scope.$index"
                  :accept="fileAccept"
                  :action="uploadFileUrl + '/file/saveFile'"
                  :before-upload="beforeUpload"
                  :on-change="(file, fileList) => handleChange(file, fileList, scope.row)"
                  :on-success="(response, file, fileList) => handleSuccess(response, file, fileList, scope.row, scope.$index, 'uploadFile' + '3'  + '_' + scope.$index)"
                  :on-remove="(file, fileList) => handleRemove(file, fileList, scope.row)"
                  :file-list="scope.row.fileList"
                  :data="{fileRemark: scope.row.fileRemark, fileuserInfo: scope.row.fileName}"
                  :multiple="false"
                  :auto-upload="true"
                >
                  <el-button
                    size="small"
                    type="primary"
                    class="el-icon-upload2"
                  ></el-button>
                </el-upload>
              </template>
            </el-table-column>
            <el-table-column
              label="操作"
              width="120"
            >
              <template #default="scope">
                <div style="display: flex; justify-content: space-around;">
                  <el-link
                    type="primary"
                    size="mini"
                    :disabled="false"
                    @click="downloadFile(scope.row)"
                  >下载</el-link>
                  <el-link
                    type="primary"
                    size="mini"
                    :disabled="false"
                    @click="handlePreviewFile({fileUuid: scope.row.fileUuid})"
                  >预览</el-link>
                </div>
              </template>
            </el-table-column>
          </el-table>
        </div>

        <el-form label-width="80px" disabled>
          <div class="box">
            <el-checkbox
              style="color: black;"
              v-model="ruleForm.factoryChecked"
            >我厂已知晓并同意本项目的xxxx,我厂承诺xxxxxxxx</el-checkbox>
            <div class="title">
              细审报告
            </div>
            <el-table
              :data="ruleForm.fileVo.REVIEW_REPORT"
              style="width: 100%; margin-bottom: 20px"
            >
              <el-table-column
                label="序号"
                width="80"
              >
                <template #default="scope">{{ scope.$index + 1 }}</template>
              </el-table-column>
              <el-table-column
                label="附件名称"
                prop="fileName"
              >
                <template #default="{row}">
                  <el-input
                    v-model="row.fileName"
                    placeholder="请输入附件名称"
                  ></el-input>
                </template>
              </el-table-column>
              <el-table-column
                label="附件说明"
                prop="fileRemark"
              >
                <template #default="{row}">
                  <el-input
                    v-model="row.fileRemark"
                    placeholder="请输入附件说明"
                  ></el-input>
                </template>
              </el-table-column>
              <el-table-column
                label="附件上传"
                prop="fileDesc"
              >
                <template #default="scope">
                  <el-upload
                    class="upload-demo"
                    :ref="'uploadFile' + '4'  + '_' + scope.$index"
                    :accept="fileAccept"
                    :action="uploadFileUrl + '/file/saveFile'"
                    :before-upload="beforeUpload"
                    :on-change="(file, fileList) => handleChange(file, fileList, scope.row)"
                    :on-success="(response, file, fileList) => handleSuccess(response, file, fileList, scope.row, scope.$index, 'uploadFile' + '4'  + '_' + scope.$index)"
                    :on-remove="(file, fileList) => handleRemove(file, fileList, scope.row)"
                    :file-list="scope.row.fileList"
                    :data="{fileRemark: scope.row.fileRemark, fileuserInfo: scope.row.fileName}"
                    :multiple="false"
                    :auto-upload="true"
                  >
                    <el-button
                      size="small"
                      type="primary"
                      class="el-icon-upload2"
                    ></el-button>
                  </el-upload>
                </template>
              </el-table-column>
              <el-table-column
                label="操作"
                width="120"
              >
                <template #default="scope">
                  <div style="display: flex; justify-content: space-around;">
                    <el-link
                      type="primary"
                      size="mini"
                      :disabled="false"
                      @click="downloadFile(scope.row)"
                    >下载</el-link>
                    <el-link
                      type="primary"
                      size="mini"
                      :disabled="false"
                      @click="handlePreviewFile({fileUuid: scope.row.fileUuid})"
                    >预览</el-link>
                  </div>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </el-form>
        <!-- <el-form label-width="80px">
          <div class="box">
            <div class="title">客户评分授信</div>
            <div style="background-color: #E8F3FC; padding: 10px; border-radius: 2px; font-size: 12px; margin-bottom: 20px;">
              {{this.ruleForm.custName}}<br>
              授信额度：{{this.ruleForm.customerCreditInfo.creditLimit}}，剩余授信额度：{{this.ruleForm.customerCreditInfo.availableLimit}}(含本项目)<br>
              上次尽调日期：{{this.ruleForm.customerCreditInfo.availableBeginTime}} 有效期至：{{this.ruleForm.customerCreditInfo.availableEndTime}}
            </div>
          </div>

          <div class="box">
            <div class="title">
              尽职调查
            </div>
            <el-form-item label="尽调结论">
              <el-input v-model="ruleForm.conclusion" />
            </el-form-item>
            <el-form-item label="建议">
              <el-input v-model="ruleForm.proposal" />
            </el-form-item>
            <el-table
              :data="ruleForm.fileVo.INVESTIGATION"
              style="width: 100%; margin-bottom: 20px"
            >
              <el-table-column
                label="序号"
                width="80"
              >
                <template #default="scope">{{ scope.$index + 1 }}</template>
              </el-table-column>
              <el-table-column
                label="附件名称"
                prop="fileName"
              >
                <template #default="{row}">
                  <el-input
                    v-model="row.fileName"
                    placeholder="请输入附件名称"
                  ></el-input>
                </template>
              </el-table-column>
              <el-table-column
                label="附件说明"
                prop="fileRemark"
              >
                <template #default="{row}">
                  <el-input
                    v-model="row.fileRemark"
                    placeholder="请输入附件说明"
                  ></el-input>
                </template>
              </el-table-column>
              <el-table-column
                label="附件上传"
                prop="fileDesc"
              >
                <template #default="scope">
                  <el-upload
                    class="upload-demo"
                    :ref="'uploadFile' + '5'  + '_' + scope.$index"
                    :accept="fileAccept"
                    :action="uploadFileUrl + '/file/saveFile'"
                    :before-upload="beforeUpload"
                    :on-change="(file, fileList) => handleChange(file, fileList, scope.row)"
                    :on-success="(response, file, fileList) => handleSuccess(response, file, fileList, scope.row, scope.$index, 'uploadFile' + '5'  + '_' + scope.$index)"
                    :on-remove="(file, fileList) => handleRemove(file, fileList, scope.row)"
                    :file-list="scope.row.fileList"
                    :data="{fileRemark: scope.row.fileRemark, fileuserInfo: scope.row.fileName}"
                    :multiple="false"
                    :auto-upload="true"
                  >
                    <el-button
                      size="small"
                      type="primary"
                      class="el-icon-upload2"
                    ></el-button>
                  </el-upload>
                </template>
              </el-table-column>
              <el-table-column
                label="操作"
                width="120"
              >
                <template #default="scope">
                  <div style="display: flex; justify-content: space-around;">
                    <el-link
                      type="primary"
                      size="mini"
                      :disabled="false"
                      @click="downloadFile(scope.row)"
                    >下载</el-link>
                    <el-link
                      type="primary"
                      size="mini"
                      :disabled="false"
                      @click="handlePreviewFile({fileUuid: scope.row.fileUuid})"
                    >预览</el-link>
                  </div>
                </template>
              </el-table-column>
            </el-table>
          </div>

          <div class="box">
            <div class="title">
              中登网信息
            </div>
            <el-table
              :data="ruleForm.fileVo.ZHONGDENG"
              style="width: 100%; margin-bottom: 20px"
            >
              <el-table-column
                label="序号"
                width="80"
              >
                <template #default="scope">{{ scope.$index + 1 }}</template>
              </el-table-column>
              <el-table-column
                label="附件名称"
                prop="fileName"
              >
                <template #default="{row}">
                  <el-input
                    v-model="row.fileName"
                    placeholder="请输入附件名称"
                  ></el-input>
                </template>
              </el-table-column>
              <el-table-column
                label="附件说明"
                prop="fileRemark"
              >
                <template #default="{row}">
                  <el-input
                    v-model="row.fileRemark"
                    placeholder="请输入附件说明"
                  ></el-input>
                </template>
              </el-table-column>
              <el-table-column
                label="附件上传"
                prop="fileDesc"
              >
                <template #default="scope">
                  <el-upload
                    class="upload-demo"
                    :ref="'uploadFile' + '6'  + '_' + scope.$index"
                    :accept="fileAccept"
                    :action="uploadFileUrl + '/file/saveFile'"
                    :before-upload="beforeUpload"
                    :on-change="(file, fileList) => handleChange(file, fileList, scope.row)"
                    :on-success="(response, file, fileList) => handleSuccess(response, file, fileList, scope.row, scope.$index, 'uploadFile' + '6'  + '_' + scope.$index)"
                    :on-remove="(file, fileList) => handleRemove(file, fileList, scope.row)"
                    :file-list="scope.row.fileList"
                    :data="{fileRemark: scope.row.fileRemark, fileuserInfo: scope.row.fileName}"
                    :multiple="false"
                    :auto-upload="true"
                  >
                    <el-button
                      size="small"
                      type="primary"
                      class="el-icon-upload2"
                    ></el-button>
                  </el-upload>
                </template>
              </el-table-column>
              <el-table-column
                label="操作"
                width="120"
              >
                <template #default="scope">
                  <div style="display: flex; justify-content: space-around;">
                    <el-link
                      type="primary"
                      size="mini"
                      :disabled="false"
                      @click="downloadFile(scope.row)"
                    >下载</el-link>
                    <el-link
                      type="primary"
                      size="mini"
                      :disabled="false"
                      @click="handlePreviewFile({fileUuid: scope.row.fileUuid})"
                    >预览</el-link>
                  </div>
                </template>
              </el-table-column>
            </el-table>
          </div>

          <div class="box">
            <div class="title">
              收益测算报告
            </div>
            <el-table
              :data="ruleForm.fileVo.CALCULATION_REPORT"
              style="width: 100%; margin-bottom: 20px"
            >
              <el-table-column
                label="序号"
                width="80"
              >
                <template #default="scope">{{ scope.$index + 1 }}</template>
              </el-table-column>
              <el-table-column
                label="附件名称"
                prop="fileName"
              >
                <template #default="{row}">
                  <el-input
                    v-model="row.fileName"
                    placeholder="请输入附件名称"
                  ></el-input>
                </template>
              </el-table-column>
              <el-table-column
                label="附件说明"
                prop="fileRemark"
              >
                <template #default="{row}">
                  <el-input
                    v-model="row.fileRemark"
                    placeholder="请输入附件说明"
                  ></el-input>
                </template>
              </el-table-column>
              <el-table-column
                label="附件上传"
                prop="fileDesc"
              >
                <template #default="scope">
                  <el-upload
                    class="upload-demo"
                    :ref="'uploadFile' + '7'  + '_' + scope.$index"
                    :accept="fileAccept"
                    :action="uploadFileUrl + '/file/saveFile'"
                    :before-upload="beforeUpload"
                    :on-change="(file, fileList) => handleChange(file, fileList, scope.row)"
                    :on-success="(response, file, fileList) => handleSuccess(response, file, fileList, scope.row, scope.$index, 'uploadFile' + '7'  + '_' + scope.$index)"
                    :on-remove="(file, fileList) => handleRemove(file, fileList, scope.row)"
                    :file-list="scope.row.fileList"
                    :data="{fileRemark: scope.row.fileRemark, fileuserInfo: scope.row.fileName}"
                    :multiple="false"
                    :auto-upload="true"
                  >
                    <el-button
                      size="small"
                      type="primary"
                      class="el-icon-upload2"
                    ></el-button>
                  </el-upload>
                </template>
              </el-table-column>
              <el-table-column
                label="操作"
                width="120"
              >
                <template #default="scope">
                  <div style="display: flex; justify-content: space-around;">
                    <el-link
                      type="primary"
                      size="mini"
                      :disabled="false"
                      @click="downloadFile(scope.row)"
                    >下载</el-link>
                    <el-link
                      type="primary"
                      size="mini"
                      :disabled="false"
                      @click="handlePreviewFile({fileUuid: scope.row.fileUuid})"
                    >预览</el-link>
                  </div>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </el-form> -->

        <el-form disabled>
          <div class="box">
            <div class="title">
              法务稽核报告
            </div>
            <el-table
              :data="ruleForm.fileVo.AUDIT_REPORT"
              style="width: 100%; margin-bottom: 20px"
            >
              <el-table-column
                label="序号"
                width="80"
              >
                <template #default="scope">{{ scope.$index + 1 }}</template>
              </el-table-column>
              <el-table-column
                label="附件名称"
                prop="fileName"
              >
                <template #default="{row}">
                  <el-input
                    v-model="row.fileName"
                    placeholder="请输入附件名称"
                  ></el-input>
                </template>
              </el-table-column>
              <el-table-column
                label="附件说明"
                prop="fileRemark"
              >
                <template #default="{row}">
                  <el-input
                    v-model="row.fileRemark"
                    placeholder="请输入附件说明"
                  ></el-input>
                </template>
              </el-table-column>
              <el-table-column
                label="附件上传"
                prop="fileDesc"
              >
                <template #default="scope">
                  <el-upload
                    class="upload-demo"
                    :ref="'uploadFile' + '8'  + '_' + scope.$index"
                    :accept="fileAccept"
                    :action="uploadFileUrl + '/file/saveFile'"
                    :before-upload="beforeUpload"
                    :on-change="(file, fileList) => handleChange(file, fileList, scope.row)"
                    :on-success="(response, file, fileList) => handleSuccess(response, file, fileList, scope.row, scope.$index, 'uploadFile' + '8'  + '_' + scope.$index)"
                    :on-remove="(file, fileList) => handleRemove(file, fileList, scope.row)"
                    :file-list="scope.row.fileList"
                    :data="{fileRemark: scope.row.fileRemark, fileuserInfo: scope.row.fileName}"
                    :multiple="false"
                    :auto-upload="true"
                  >
                    <el-button
                      size="small"
                      type="primary"
                      class="el-icon-upload2"
                    ></el-button>
                  </el-upload>
                </template>
              </el-table-column>
              <el-table-column
                label="操作"
                width="120"
              >
                <template #default="scope">
                  <div style="display: flex; justify-content: space-around;">
                    <el-link
                      type="primary"
                      size="mini"
                      :disabled="false"
                      @click="downloadFile(scope.row)"
                    >下载</el-link>
                    <el-link
                      type="primary"
                      size="mini"
                      :disabled="false"
                      @click="handlePreviewFile({fileUuid: scope.row.fileUuid})"
                    >预览</el-link>
                  </div>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </el-form>

        <el-form disabled>
          <div class="box">
            <div class="title">
              风险审查意见表
            </div>
            <el-table
              :data="ruleForm.fileVo.RISK_REVIEW"
              style="width: 100%; margin-bottom: 20px"
            >
              <el-table-column
                label="序号"
                width="80"
              >
                <template #default="scope">{{ scope.$index + 1 }}</template>
              </el-table-column>
              <el-table-column
                label="附件名称"
                prop="fileName"
              >
                <template #default="{row}">
                  <el-input
                    v-model="row.fileName"
                    placeholder="请输入附件名称"
                  ></el-input>
                </template>
              </el-table-column>
              <el-table-column
                label="附件说明"
                prop="fileRemark"
              >
                <template #default="{row}">
                  <el-input
                    v-model="row.fileRemark"
                    placeholder="请输入附件说明"
                  ></el-input>
                </template>
              </el-table-column>
              <el-table-column
                label="附件上传"
                prop="fileDesc"
              >
                <template #default="scope">
                  <el-upload
                    class="upload-demo"
                    :ref="'uploadFile' + '9'  + '_' + scope.$index"
                    :accept="fileAccept"
                    :action="uploadFileUrl + '/file/saveFile'"
                    :before-upload="beforeUpload"
                    :on-change="(file, fileList) => handleChange(file, fileList, scope.row)"
                    :on-success="(response, file, fileList) => handleSuccess(response, file, fileList, scope.row, scope.$index, 'uploadFile' + '9'  + '_' + scope.$index)"
                    :on-remove="(file, fileList) => handleRemove(file, fileList, scope.row)"
                    :file-list="scope.row.fileList"
                    :data="{fileRemark: scope.row.fileRemark, fileuserInfo: scope.row.fileName}"
                    :multiple="false"
                    :auto-upload="true"
                  >
                    <el-button
                      size="small"
                      type="primary"
                      class="el-icon-upload2"
                    ></el-button>
                  </el-upload>
                </template>
              </el-table-column>
              <el-table-column
                label="操作"
                width="120"
              >
                <template #default="scope">
                  <div style="display: flex; justify-content: space-around;">
                    <el-link
                      type="primary"
                      size="mini"
                      :disabled="false"
                      @click="downloadFile(scope.row)"
                    >下载</el-link>
                    <el-link
                      type="primary"
                      size="mini"
                      :disabled="false"
                      @click="handlePreviewFile({fileUuid: scope.row.fileUuid})"
                    >预览</el-link>
                  </div>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </el-form>

        <el-form disabled>
          <div class="box">
            <div class="title">
              会议纪要
            </div>
            <el-table
              :data="ruleForm.fileVo.MEETING_MINUTES"
              style="width: 100%; margin-bottom: 20px"
            >
              <el-table-column
                label="序号"
                width="80"
              >
                <template #default="scope">{{ scope.$index + 1 }}</template>
              </el-table-column>
              <el-table-column
                label="附件名称"
                prop="fileName"
              >
                <template #default="{row}">
                  <el-input
                    v-model="row.fileName"
                    placeholder="请输入附件名称"
                  ></el-input>
                </template>
              </el-table-column>
              <el-table-column
                label="附件说明"
                prop="fileRemark"
              >
                <template #default="{row}">
                  <el-input
                    v-model="row.fileRemark"
                    placeholder="请输入附件说明"
                  ></el-input>
                </template>
              </el-table-column>
              <el-table-column
                label="附件上传"
                prop="fileDesc"
              >
                <template #default="scope">
                  <el-upload
                    class="upload-demo"
                    :ref="'uploadFile' + '10'  + '_' + scope.$index"
                    :accept="fileAccept"
                    :action="uploadFileUrl + '/file/saveFile'"
                    :before-upload="beforeUpload"
                    :on-change="(file, fileList) => handleChange(file, fileList, scope.row)"
                    :on-success="(response, file, fileList) => handleSuccess(response, file, fileList, scope.row, scope.$index, 'uploadFile' + '10'  + '_' + scope.$index)"
                    :on-remove="(file, fileList) => handleRemove(file, fileList, scope.row)"
                    :file-list="scope.row.fileList"
                    :data="{fileRemark: scope.row.fileRemark, fileuserInfo: scope.row.fileName}"
                    :multiple="false"
                    :auto-upload="true"
                  >
                    <el-button
                      size="small"
                      type="primary"
                      class="el-icon-upload2"
                    ></el-button>
                  </el-upload>
                </template>
              </el-table-column>
              <el-table-column
                label="操作"
                width="120"
              >
                <template #default="scope">
                  <div style="display: flex; justify-content: space-around;">
                    <el-link
                      type="primary"
                      size="mini"
                      :disabled="false"
                      @click="downloadFile(scope.row)"
                    >下载</el-link>
                    <el-link
                      type="primary"
                      size="mini"
                      :disabled="false"
                      @click="handlePreviewFile({fileUuid: scope.row.fileUuid})"
                    >预览</el-link>
                  </div>
                </template>
              </el-table-column>
            </el-table>
          </div>

          <div class="box">
            <div class="title">
              项目批复书
            </div>
            <el-table
              :data="ruleForm.fileVo.PROJECT_APPROVAL"
              style="width: 100%; margin-bottom: 20px"
            >
              <el-table-column
                label="序号"
                width="80"
              >
                <template #default="scope">{{ scope.$index + 1 }}</template>
              </el-table-column>
              <el-table-column
                label="附件名称"
                prop="fileName"
              >
                <template #default="{row}">
                  <el-input
                    v-model="row.fileName"
                    placeholder="请输入附件名称"
                  ></el-input>
                </template>
              </el-table-column>
              <el-table-column
                label="附件说明"
                prop="fileRemark"
              >
                <template #default="{row}">
                  <el-input
                    v-model="row.fileRemark"
                    placeholder="请输入附件说明"
                  ></el-input>
                </template>
              </el-table-column>
              <el-table-column
                label="附件上传"
                prop="fileDesc"
              >
                <template #default="scope">
                  <el-upload
                    class="upload-demo"
                    :ref="'uploadFile' + '11'  + '_' + scope.$index"
                    :accept="fileAccept"
                    :action="uploadFileUrl + '/file/saveFile'"
                    :before-upload="beforeUpload"
                    :on-change="(file, fileList) => handleChange(file, fileList, scope.row)"
                    :on-success="(response, file, fileList) => handleSuccess(response, file, fileList, scope.row, scope.$index, 'uploadFile' + '11'  + '_' + scope.$index)"
                    :on-remove="(file, fileList) => handleRemove(file, fileList, scope.row)"
                    :file-list="scope.row.fileList"
                    :data="{fileRemark: scope.row.fileRemark, fileuserInfo: scope.row.fileName}"
                    :multiple="false"
                    :auto-upload="true"
                  >
                    <el-button
                      size="small"
                      type="primary"
                      class="el-icon-upload2"
                    ></el-button>
                  </el-upload>
                </template>
              </el-table-column>
              <el-table-column
                label="操作"
                width="120"
              >
                <template #default="scope">
                  <div style="display: flex; justify-content: space-around;">
                    <el-link
                      type="primary"
                      size="mini"
                      :disabled="false"
                      @click="downloadFile(scope.row)"
                    >下载</el-link>
                    <el-link
                      type="primary"
                      size="mini"
                      :disabled="false"
                      @click="handlePreviewFile({fileUuid: scope.row.fileUuid})"
                    >预览</el-link>
                  </div>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </el-form>
      </el-card>
      <RentCalculation ref="rentCalculationRef"></RentCalculation>

      <AgentTable
        ref="agentTableRef"
        @ok="handleAgentOk"
      ></AgentTable>
      <CustomTable
        ref="customTableRef"
        @ok="handleCustOk"
      ></CustomTable>
      <EquipmentTable
        ref="equipmentTableRef"
        @ok="handleEquipmentOk"
      ></EquipmentTable>
      <CustomerBankDialog
        ref="customerBankRef"
        @ok="handleCustomerBankOk"
      />
      <PreviewFile
        :fileType="fileType"
        :fileUrl="fileUrl"
        :dialogVisible="dialogFileVisible"
        @cancel="dialogFileVisible = false"
      />
    </el-form>
  </el-dialog>
</template>

<script>
import AgentTable from './AgentTable'
import CustomTable from "./CustomTable"
import EquipmentTable from './EquipmentTable'
import HskAddressSel from '@/components/area/index.vue'
import RentCalculation from "./RentCalculation"
import enumMixins from './enumMixins'
import { getNodeUsers, queryFiles, getCompanyList, customerCreditInfo, removeCustomerBank, allCustomerBank } from '@/api/processManage/approveForms'
import { getDownload } from '@/utils/request'
import { mapState } from "vuex";
import { formatMoney, numToChinaNumerals, previewFile } from "@/utils/utils"
import CustomerBankDialog from "./components/CustomerBankDialog.vue";
import PreviewFile from '@/components/PreviewFile/index'

export default {
  components: {
    AgentTable,
    CustomTable,
    EquipmentTable,
    HskAddressSel,
    RentCalculation,
    CustomerBankDialog,
    PreviewFile
  },
  mixins: [enumMixins],
  dicts: ['sys_file_template', 'enabled_file_upload_types', 'sys_rent', 'sys_user_sex', 'sys_nation', 'sys_education'],
  computed: {
    // 计算首付款比例(首付款/合同价款)
    downPaymentPercentage() {
      if (this.ruleForm.rentCalculateVo.calculateInfo.downPayment && this.ruleForm.rentCalculateVo.calculateInfo.leasingPrice) {
        return parseFloat(((this.ruleForm.rentCalculateVo.calculateInfo.downPayment / this.ruleForm.rentCalculateVo.calculateInfo.leasingPrice) * 100).toFixed(2))
      }
      return undefined
    },
    // 计算保证金比例(保证金/合同价款)
    marginPercentage() {
      if (this.ruleForm.rentCalculateVo.calculateInfo.margin && this.ruleForm.rentCalculateVo.calculateInfo.leasingPrice) {
        return parseFloat(((this.ruleForm.rentCalculateVo.calculateInfo.margin / this.ruleForm.rentCalculateVo.calculateInfo.leasingPrice) * 100).toFixed(2))
      }
      return undefined
    },
    // 计算手续费率(年)(手续费/合同价款)
    feeRatePerYear() {
      if (this.ruleForm.rentCalculateVo.calculateInfo.fees && this.ruleForm.rentCalculateVo.calculateInfo.leasingPrice) {
        return parseFloat(((this.ruleForm.rentCalculateVo.calculateInfo.fees) / parseFloat(this.ruleForm.rentCalculateVo.calculateInfo.leasingPrice) * 100).toFixed(2))
      }
      return undefined
    },
    ...mapState({
      username: state => state.user.name
    }),
    formatLeasingPrice() {
      return numToChinaNumerals(this.ruleForm.rentCalculateVo.calculateInfo.leasingPrice)
    },
    formatDownPayment() {
      return numToChinaNumerals(this.ruleForm.rentCalculateVo.calculateInfo.downPayment)
    },
    formatMargin() {
      return numToChinaNumerals(this.ruleForm.rentCalculateVo.calculateInfo.margin)
    },
    formatFees() {
      return numToChinaNumerals(this.ruleForm.rentCalculateVo.calculateInfo.fees)
    },
    formatOtherIncomeTaxIncluded() {
      return numToChinaNumerals(this.ruleForm.rentCalculateVo.calculateInfo.otherIncomeTaxIncluded)
    },
    formatLessorOtherCosts() {
      return numToChinaNumerals(this.ruleForm.rentCalculateVo.calculateInfo.lessorOtherCosts)
    }
  },
  data() {
    return {
      uploadFileUrl: process.env.VUE_APP_BASE_API,
      approveList: [],
      hrefn: require("@/assets/images/space.png"),
      ruleForm: {
        custName: '',
        custNo: '',
        targetUserName: '',
        bankAccountList: [], // 开户行
        customerAdmitVo: { // 客户准入信息
          customerAdmitInfo: {}
        },
        customerCreditInfo: {}, // 授信评分信息
        equipmentVos: [], // 设备
        // 附件
        fileVo: {
          FINANCING: [], // 融资清单
          GUARANTEE: [], // 担保信息
          OTHER: [], // 其他材料补充
          REVIEW_REPORT: [], // 细审报告
          INVESTIGATION: [], // 尽职调查
          ZHONGDENG: [], // 中登网信息
          CALCULATION_REPORT: [], // 收益测算报告
          AUDIT_REPORT: [], // 法务稽核报告
          RISK_REVIEW: [], // 风险审查意见表
          MEETING_MINUTES: [], // 会议纪要
          PROJECT_APPROVAL: [], // 项目批复书
        },
        projectBasicVo: { // 项目申请基本信息
          agentName: '', // 代理商名称
          applicationFileId: '', // 立项报告
          applyFileId: '', // 承租企业近期融资情况id
          financeFileId: '', // 承租企业近年主要财务指标id
          financeingDesc: '', // 融资清单资料补充说明
          guaraDesc: '', // 担保补充说明
          guaraWay: [], // 担保方式
          mailAddr: [], // 邮寄地址
          mailDetailAddr: '', // 邮寄详细地址
          projectAddr: [], // 项目地址
          projectDesc: '', // 项目说明
          recipientName: '', // 收件人名称
          recipientPhone: '', // 收件人电话
          rentType: '01', // 租赁类型
          invoice_title: '', // 发票抬头
          tax_no: '', // 开票税号
          invoice_address: '', // 开票地址
          invoice_tle: '', // 开票联系电话
          invoice_bank: '', // 开票开户行
          invoice_account: '', // 开票银行账户
          lessorId: null, // 出租方id
          relatedFactoryId: '', // 设备厂商id
          relatedFactoryName: '', // 设备厂商名称
          contractAmount: 0, // 合同金额
        },
        rentCalculateVo: { // 测算基本信息
          calculateInfo: {
            leasingPrice: '', // 合同价款
            leaseTermMonths: 24, // 融资期限(月)
            leasingMethod: 'DIRECT', // 租赁方式
            repaymentMethod: 'EQUAL_PRINCIPAL_AND_INTEREST', // 还款方式
            startDay: undefined, // 起始日
            breakPeriod: undefined, // 停歇期
            repaymentCycle: 'MONTHLY', // 还款周期
            gracePeriodMonths: 2, // 宽限期(月)
            marginDeductionMethod: undefined, // 保证金抵扣方式
            rentPaymentTiming: 'END', // 还租时点
            downPaymentPercentage: undefined, // 首付款比例
            marginPercentage: undefined, // 保证金比例
            feeRatePerYear: undefined, // 手续费率(年)
            feeTaxRate: 6, // 手续费税率
            nominalInterestRate: 10, // 名义收益率
            capitalCostRate: 7, // 资金成本率
            lessorOtherCosts: 0, // 出租人其他成本
            otherIncomeTaxIncluded: 0, // 其他收入(含税)
            downPayment: 0, // 首付款
            margin: 0, // 保证金
            fees: 0, // 手续费
            monthlyPayment: undefined, // 每日支付
          }
        },
        factoryChecked: false, // 工厂审核是否已知晓
        conclusion: '', // 尽调结论
        proposal: '', // 建议
      },
      defaultProjectAddress: [],
      defaultMailAddress: [],
      rules: {
        'customerAdmitVo.customerAdmitInfo.customerName': [{ required: true, message: '请选择客户', trigger: 'change' }],
        targetUserName: [{ required: true, message: '请选择下一节点审批人', trigger: 'blur' }],
        'projectBasicVo.lessorId': [{ required: true, message: '请选择出租方', trigger: 'blur' }],
        'rentCalculateVo.calculateInfo.leasingPrice': [{ required: true, message: '请输入合同价款', trigger: 'blur' }],
      },
      financeFile: [],
      applyFile: [],
      applicationFile: [],
      inputNumShow: 4,
      inputInterval: 10,
      checkList: [],
      imitateShow: false,
      tableKey: 0,
      lessorList: [],
      fileTemplate: {},
      fileAccept: '',
      sexEnum: {
        "1": "男",
        "2": "女"
      },
      creditEnum: {
        "1": "很好",
        "2": "良好",
        "3": "一般",
        "4": "差",
      },
      marriageEnum: {
        "1": "未婚",
        "0": "已婚"
      },

      fileUrl: '',
      fileType: '',
      dialogFileVisible: false,

      dialogProjectVisible: false
    }
  },
  created() {
    this.getLessor()
  },
  watch: {
    'dict.type.sys_file_template': function (newVal) {
      newVal.forEach(item => {
        item.remark = item.raw.remark
        this.fileTemplate[item.label] = item
      })
    },
    'dict.type.enabled_file_upload_types': {
      deep: true,
      handler(newValue) {
        if (newValue && newValue.length > 0) {
          this.fileAccept = newValue.map(item => {
            let updatedValue = item.value.split(',').map(item => `.${item}`).join(',');
            return updatedValue;
          }).join(',');
        }
      }
    }
  },
  methods: {
    open(row) {
      this.ruleForm = {
        ...JSON.parse(JSON.stringify(row)),
        customerAdmitVo: {
          customerAdmitInfo: JSON.parse(row.customerAdmitVo.customerAdmitInfo || "{}")
        },
        rentCalculateVo: {
          calculateInfo: JSON.parse(row.rentCalculateVo.calculateInfo || "{}")
        },
        fileVo: {
          AUDIT_REPORT: row.fileVo.AUDIT_REPORT && row.fileVo.AUDIT_REPORT.map(item => {
            return {
              ...item,
              fileUuid: item.fileId,
              fileRemark: item.fileDesc,
              fileList: [{name: item.fileName}]
            }
          }),
          CALCULATION_REPORT: row.fileVo.CALCULATION_REPORT && row.fileVo.CALCULATION_REPORT.map(item => {
            return {
              ...item,
              fileUuid: item.fileId,
              fileRemark: item.fileDesc,
              fileList: [{name: item.fileName}]
            }
          }),
          FINANCING: row.fileVo.FINANCING && row.fileVo.FINANCING.map(item => {
            return {
              ...item,
              fileUuid: item.fileId,
              fileRemark: item.fileDesc,
              fileList: [{name: item.fileName}]
            }
          }),
          GUARANTEE: row.fileVo.GUARANTEE && row.fileVo.GUARANTEE.map(item => {
            return {
              ...item,
              fileUuid: item.fileId,
              fileRemark: item.fileDesc,
              fileList: [{name: item.fileName}]
            }
          }),
          INVESTIGATION: row.fileVo.INVESTIGATION && row.fileVo.INVESTIGATION.map(item => {
            return {
              ...item,
              fileUuid: item.fileId,
              fileRemark: item.fileDesc,
              fileList: [{name: item.fileName}]
            }
          }),
          MEETING_MINUTES: row.fileVo.MEETING_MINUTES && row.fileVo.MEETING_MINUTES.map(item => {
            return {
              ...item,
              fileUuid: item.fileId,
              fileRemark: item.fileDesc,
              fileList: [{name: item.fileName}]
            }
          }),
          OTHER: row.fileVo.OTHER && row.fileVo.OTHER.map(item => {
            return {
              ...item,
              fileUuid: item.fileId,
              fileRemark: item.fileDesc,
              fileList: [{name: item.fileName}]
            }
          }),
          PROJECT_APPROVAL: row.fileVo.PROJECT_APPROVAL && row.fileVo.PROJECT_APPROVAL.map(item => {
            return {
              ...item,
              fileUuid: item.fileId,
              fileRemark: item.fileDesc,
              fileList: [{name: item.fileName}]
            }
          }),
          REVIEW_REPORT: row.fileVo.REVIEW_REPORT && row.fileVo.REVIEW_REPORT.map(item => {
            return {
              ...item,
              fileUuid: item.fileId,
              fileRemark: item.fileDesc,
              fileList: [{name: item.fileName}]
            }
          }),
          RISK_REVIEW: row.fileVo.RISK_REVIEW && row.fileVo.RISK_REVIEW.map(item => {
            return {
              ...item,
              fileUuid: item.fileId,
              fileRemark: item.fileDesc,
              fileList: [{name: item.fileName}]
            }
          }),
          ZHONGDENG: row.fileVo.ZHONGDENG && row.fileVo.ZHONGDENG.map(item => {
            return {
              ...item,
              fileUuid: item.fileId,
              fileRemark: item.fileDesc,
              fileList: [{name: item.fileName}]
            }
          })
        }
      }
      this.ruleForm.projectBasicVo.projectAddr = this.ruleForm.projectBasicVo.projectAddr?.split(",")
      this.ruleForm.projectBasicVo.mailAddr = this.ruleForm.projectBasicVo.mailAddr?.split(":")[0].split(",")
      this.ruleForm.projectBasicVo.guaraWay = this.ruleForm.projectBasicVo.guaraWay?.split(",")
      this.defaultProjectAddress = [...this.ruleForm.projectBasicVo.projectAddr] || []
      this.defaultMailAddress = [...this.ruleForm.projectBasicVo.mailAddr] || []
      this.createFileUrl(this.ruleForm.customerAdmitVo.customerAdmitInfo.licenseId, "hrefn")
      this.createFileUrl(this.ruleForm.customerAdmitVo.customerAdmitInfo.idCardFront, "frontFn")
      this.createFileUrl(this.ruleForm.customerAdmitVo.customerAdmitInfo.idCardReverse, "backFn")
      this.dialogProjectVisible = true

      console.log(this.ruleForm);

    },
    handleProjectClose() {
      this.dialogProjectVisible = false
    },
    // 文件预览
    async handlePreviewFile(row) {
      try {
        const { arrayBuffer, fileType } = await previewFile({ fileUuid: row.fileUuid });
        this.fileUrl = arrayBuffer;
        this.fileType = fileType;
        this.dialogFileVisible = true
      } catch (error) {
        this.$modal.msgError(error.message);
      }
    },
    beforeUpload(file) {
      if (file.size / 1024 / 1024 > 50) {
        this.$message.error('文件不能超过50M！');
        return false;
      }
      return true;
    },
    handleFinanceChange(file, fileList, v) {
      this.financeFile.push(file)
      if (this.financeFile.length > 0) {
        this.financeFile = [fileList[fileList.length - 1]]
      }
      return true
    },
    handleFinanceSuccess(response, file) {
      let uid = file.uid
      let idx = this.$refs.uploadFinanceFile.uploadFiles.findIndex(item => item.uid == uid)
      if (response.code != 200) {
        this.$modal.msgError('文件格式或命名存在特殊字符,请检查后重新上传!');
        this.$refs.uploadFinanceFile.uploadFiles.splice(idx, 1)
        return true;
      }

      this.ruleForm.projectBasicVo.financeFileId = response.data.fileUuid;
      this.financeFile.push(file)
    },

    handleFinanceRemove(file, fileList) {
      this.financeFile = fileList
      if (!this.financeFile.length) {
        this.ruleForm.projectBasicVo.financeFileId = ''
      }
    },

    handleApplyDescChange(file, fileList, v) {
      this.applyFile.push(file)
      if (this.applyFile.length > 0) {
        this.applyFile = [fileList[fileList.length - 1]]
      }
      return true
    },
    handleApplySuccess(response, file) {
      let uid = file.uid
      let idx = this.$refs.uploadApplyDescFile.uploadFiles.findIndex(item => item.uid == uid)
      if (response.code != 200) {
        this.$modal.msgError('文件格式或命名存在特殊字符,请检查后重新上传!');
        this.$refs.uploadApplyDescFile.uploadFiles.splice(idx, 1)
        return true;
      }

      this.ruleForm.projectBasicVo.applyFileId = response.data.fileUuid;
      this.applyFile.push(file)
    },


    handleApplyDescRemove(file, fileList) {
      this.applyFile = fileList
      if (!this.applyFile.length) {
        this.ruleForm.projectBasicVo.applyFileId = ''
      }
    },

    handleApplicationChange(file, fileList, v) {
      this.applicationFile.push(file)
      if (this.applicationFile.length > 0) {
        this.applicationFile = [fileList[fileList.length - 1]]
      }
      return true
    },
    handleApplicationSuccess(response, file) {
      let uid = file.uid
      let idx = this.$refs.uploadApplicationFile.uploadFiles.findIndex(item => item.uid == uid)
      if (response.code != 200) {
        this.$modal.msgError('文件格式或命名存在特殊字符,请检查后重新上传!');
        this.$refs.uploadApplicationFile.uploadFiles.splice(idx, 1)
        return true;
      }

      this.ruleForm.projectBasicVo.applicationFileId = response.data.fileUuid;
      this.applicationFile.push(file)
    },

    handleApplicationRemove(file, fileList) {
      this.applicationFile = fileList
      if (!this.applicationFile.length) {
        this.ruleForm.projectBasicVo.applicationFileId = ''
      }
    },
    // 新增银行账号
    handleAddCustomerBank() {
      if (!this.ruleForm.custNo) {
        this.$message.error("请先选择客户")
        return
      }
      this.$refs.customerBankRef.open({
        customerId: this.ruleForm.custNo,
        customerName: this.ruleForm.custName
      }, "add")
    },
    // 编辑银行账号
    handleEditCustomerBank(row) {
      this.$refs.customerBankRef.open(row, "edit");
    },
    // 删除银行账号
    handleDelCustomerBank(row, index) {
      removeCustomerBank(row.id).then(res => {
        if (res.code === 200) {
          this.ruleForm.bankAccountList.splice(index, 1)
        } else {
          this.$message.error(res.msg)
        }
      })
    },
    // 新增或编辑成功后回调
    handleCustomerBankOk(customerId) {
      allCustomerBank({ customerId }).then(res => {
        if (res.code === 200) {
          this.ruleForm.bankAccountList = res.data
        } else {
          this.$message.error(res.msg)
        }
      })
    },
    handleDel(i, type) {
      this.ruleForm[type].splice(i, 1);
      if (type === 'equipmentVos') {
        this.getSummaries({
          columns: this.$refs.table.columns,
          data: this.ruleForm.equipmentVos
        })
      }
    },

    handleChange(file, fileList, v) {
      if (v.fileList.length > 0) {
        v.fileList = [fileList[fileList.length - 1]]
      }
      return true
    },
    handleSuccess(response, file, fileList, v, i, uploadName) {
      let uid = file.uid
      let idx = this.$refs[uploadName].uploadFiles.findIndex(item => item.uid == uid)
      if (response.code != 200) {
        this.$modal.msgError('文件格式或命名存在特殊字符,请检查后重新上传!');
        this.$refs[uploadName].uploadFiles.splice(idx, 1)
        return true;
      }

      v.fileName = response.data.fileName;
      v.fileUuid = response.data.fileUuid;
      v.fileId = response.data.fileUuid
      v.fileList.push(file)
    },

    handleRemove(file, fileList, v) {
      v.fileList = fileList
      if (!v.fileList.length) {
        v.fileId = ''
        v.fileName = ''
        v.fileUuid = ''
      }
    },

    deleteFileList(row, index) {
      row.splice(index, 1);
    },
    addFileList(row) {
      row.push({
        fileName: '',
        fileUuid: '',
        fileId: '',
        fileRemark: '',
        fileList: []
      })
    },

    // 获取出租方列表
    getLessor() {
      getCompanyList("flcompany").then(res => {
        this.lessorList = res.rows
      })
    },

    // 选择代理商
    handleAgentClick() {
      this.$refs.agentTableRef.sync()
    },
    handleAgentOk(row) {
      this.ruleForm.projectBasicVo.agentName = row.agentName
    },

    // 选择客户
    handleCustClick() {
      this.$refs.customTableRef.sync()
    },
    handleCustOk(row) {
      // this.ruleForm.customerAdmitVo.customerAdmitInfo = row
      this.createFileUrl(row.licenseId, "hrefn")
      this.createFileUrl(row.idCardFront, "frontFn")
      this.createFileUrl(row.idCardReverse, "backFn")
      this.ruleForm.custName = row.customerName
      this.ruleForm.custNo = row.customerId
      this.ruleForm.projectBasicVo.invoice_title = row.customerName
      this.ruleForm.projectBasicVo.tax_no = row.creditCode
      this.ruleForm.projectBasicVo.customerName = row.userName
      this.ruleForm.projectBasicVo.customerNickName = row.customerName
      customerCreditInfo({ customerId: row.customerId }).then(res => {
        if (res.data) {
          this.ruleForm.customerCreditInfo = res.data
        } else {
          this.$message.warning("当前客户未进行授信评分")
        }
      })
      this.handleCustomerBankOk(row.customerId)
    },
    createFileUrl(fileUuid, field) {
      if (!fileUuid) {
        this.$set(this.ruleForm.customerAdmitVo.customerAdmitInfo, field, this.hrefn)
        return
      }
      queryFiles({
        fileId: fileUuid,
        modelKey: 'original'
      }).then(res => {
        const blob = new Blob([res], { type: "image/jpeg" })
        const fileUrl = window.URL.createObjectURL(blob);
        this.$set(this.ruleForm.customerAdmitVo.customerAdmitInfo, field, fileUrl)
      })
    },

    // 选择设备
    handleEquipmentClick() {
      this.$refs.equipmentTableRef.sync()
    },
    handleEquipmentOk(row) {
      if (this.ruleForm.equipmentVos.length > 0 && this.ruleForm.equipmentVos.filter(item => item.companyCode !== row.companyCode).length > 0) {
        this.$message.error("只能选择同一个工厂的设备")
        return
      }
      this.ruleForm.projectBasicVo.relatedFactoryId = row.companyCode
      this.ruleForm.projectBasicVo.relatedFactoryName = row.company
      this.ruleForm.equipmentVos.push({
        ...row,
        num: 1,
        totalPrice: 0
      })
      this.tableKey += 1;
    },

    handleImitateOpen() {
      let params = {
        ...this.ruleForm.rentCalculateVo.calculateInfo,
        downPaymentPercentage: this.downPaymentPercentage,
        marginPercentage: this.marginPercentage,
        feeRatePerYear: this.feeRatePerYear
      }
      this.$refs.rentCalculationRef.sync(params)
    },
    handlePrice(row) {
      row.totalPrice = row.num * (row.price || 0)
      return row.num * (row.price || 0)
    },
    getSummaries(param) {
      const { columns, data } = param;
      const sums = [];
      columns.forEach((column, index) => {
        // 对于不需要计算的列，直接设置为空字符串
        if ([0, 1, 2, 3, 4].includes(index)) {
          sums[index] = '';
          return;
        }
        if ([5].includes(index)) {
          sums[index] = '合计总金额';
          return;
        }
        // 对于“总价”列，进行特殊处理
        if (index === 6) {
          // 初始化总价为0
          let totalPriceSum = 0;
          // 遍历数据行，累加有效总价
          data.forEach(item => {

            const totalPrice = Number(item[column.property]);
            if (!isNaN(totalPrice)) {
              totalPriceSum += totalPrice;
            }
          });
          // 设置合计总金额，并添加单位
          sums[index] = `${totalPriceSum.toFixed(2)}`
          sums[7] = numToChinaNumerals(totalPriceSum ?? 0)
        }
      });
      return sums;
    },

    addressChange(e) {
      this.ruleForm.projectBasicVo.projectAddr = e
    },
    addressChanges(e) {
      this.ruleForm.projectBasicVo.mailAddr = e
    },
    // 校验除rules之外的字段
    validate() {
      if (this.ruleForm.equipmentVos.length === 0) {
        this.$message.error("设备列表不能为空")
        return false;
      }
      let res = true
      this.ruleForm.equipmentVos.forEach(item => {
        if (!item.price) {
          this.$message.error(`设备${item.equipmentName}单价不能为空`)
          res = false
        }
      })
      if (this.flowInfo.currNodeId === '1' && !this.ruleForm.factoryChecked) {
        this.$message.error("请勾选是否同意")
        res = false;
      }
      return res;
    },
    getNewDoc() {
      let params = JSON.parse(JSON.stringify(this.ruleForm))
      params.projectBasicVo.projectAddr = this.ruleForm.projectBasicVo.projectAddr.join(',')
      params.projectBasicVo.guaraWay = this.ruleForm.projectBasicVo.guaraWay.join(',')
      params.projectBasicVo.mailAddr = this.ruleForm.projectBasicVo.mailAddr.join(',') + ":" + this.ruleForm.projectBasicVo.mailDetailAddr
      this.ruleForm.rentCalculateVo.calculateInfo.type = "common"
      params.customerAdmitVo.customerAdmitInfo = JSON.stringify(this.ruleForm.customerAdmitVo.customerAdmitInfo, (key, value) => {
        if (["hrefn", "frontFn", "backFn"].includes(key)) {
          return ""
        }
        return value
      })
      params.rentCalculateVo.calculateInfo = JSON.stringify(this.ruleForm.rentCalculateVo.calculateInfo)
      params.projectBasicVo.contractAmount = this.ruleForm.rentCalculateVo.calculateInfo.leasingPrice
      return {
        ...params,
        flag: this.ruleForm.flag,
        flowNo: this.flowNo || ''
      }
    },
    handleSubmit(flag) {
      this.ruleForm.flag = flag
      this.$refs['ruleForm'].validate((valid) => {
        if (valid) {
          this.$emit('submit', this.getNewDoc());
        } else {
          this.$message.error(this.$refs['ruleForm'].fields.find(field => field.validateMessage).validateMessage)
          return false
        }
      })
    },
    handleRepaymentCycleChange() {
      if (this.ruleForm.rentCalculateVo.calculateInfo.repaymentCycle !== 'MONTHLY') {
        this.ruleForm.rentCalculateVo.calculateInfo.breakPeriod = undefined
      }
    },
    // 下载模板文件
    downloadTemplateFile(url) {
      this.$message.success('下载已开始，请耐心等待，请勿重复点击')
      const a = document.createElement('a') // 创建一个<a></a>标签
      a.href = url // 下载文件地址
      // a.download = '太重集团（工起）合同管理平台使用培训手册.pptx' // 下载文件名字
      a.style.display = 'none'
      document.body.appendChild(a) // 将a标签追加到文档对象中
      a.click() // 模拟点击<a>标签,触发<a>标签的href的读取,浏览器自动下载文件
      a.remove() // 用完删除a标签
    },
    downloadFile(row) {
      getDownload(row.fileUuid, row.fileName)
    },
    downloadFileList(list) {
      list.forEach(item => {
        getDownload(item.fileUuid)
      })
    },
    formatMoney,
  }
}
</script>

<style lang="scss" scoped>
.box-card {
    margin-bottom: 20px;
  }
.box {
  margin-bottom: 10px;
  .title {
    margin-bottom: 10px;
    font-size: 21px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .box-card {
    margin-bottom: 10px;
  }
}
.upload-demo {
  display: flex;
  align-items: center;
}
::v-deep .address-container .el-select {
  width: 133px;
}
.tz-icon-ppt {
  &:before {
    content: url("~@/assets/images/formApproal/icon-ppt.png");
  }
}
.tz-icon-doc {
  &:before {
    content: url("~@/assets/images/formApproal/icon-doc.png");
  }
}
.tz-icon-pdf {
  &:before {
    content: url("~@/assets/images/formApproal/icon-pdf.png");
  }
}
.tz-icon-add {
  &:before {
    content: url("~@/assets/images/formApproal/icon-add.png");
    padding-right: 5px;
  }
}
</style>
